package com.yecheng.yeaiagent.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.stereotype.Component;

/**
 * ChatClient调用
 */
@Component
public class SpringAiAiInvoke2 {

    private final ChatClient chatClient;

//    @Resource
//    private ChatModel chatModel;

    /**
     * 构造器注入
     * @param chatClientBuilder
     */
    public SpringAiAiInvoke2(ChatClient.Builder chatClientBuilder) {
        this.chatClient = chatClientBuilder
                .defaultSystem("你是恋爱顾问")
                .build();
    }

    public void TestAi1(){
//        建造者模式注入
//        ChatClient chatClient = ChatClient.builder(chatModel)
//               .defaultSystem("你是恋爱顾问")
//                .build();

        String content = chatClient.prompt("你好，我是郭嘉嘉，我想知道你对我有什么建议")
                .call()
                .content();
        System.out.println(content);
    }

}


